#pragma once

#include<iostream>
#include<fstream>
#include<boost/algorithm/string.hpp>

#include"cppjieba/include/cppjieba/Jieba.hpp"
namespace ns_util
{
    class FileUtil
    {
    public:
        static bool ReadFile(const std::string file_path,std::string* result)
        {
            std::ifstream in(file_path,std::ios::in);
            if(!in.is_open())
            {
                std::cerr<<"open file :" <<file_path <<" error !"<<std::endl;
                return false;
            }
            std::string line;
            while(std::getline(in,line))
            {
                *result += line;
            }

            in.close();
            return true;
        }
    };

    class StringSplit
    {
    public:
        static void SplitString(std::string line,std::vector<std::string>* result,const std::string sep)
        {
            boost::split(*result,line,boost::is_any_of(sep),boost::token_compress_on);
        }
    };
    const char* const DICT_PATH = "./cppjieba/dict/jieba.dict.utf8";
    const char* const HMM_PATH = "./cppjieba/dict/hmm_model.utf8";
    const char* const USER_DICT_PATH = "./cppjieba/dict/user.dict.utf8";
    const char* const IDF_PATH = "./cppjieba/dict/idf.utf8";
    const char* const STOP_WORD_PATH = "./cppjieba/dict/stop_words.utf8";
    class JiebaUtil
    {
    public:
        static void CutString(std::string input,std::vector<std::string>* results)
        {
            jieba.CutForSearch(input,*results);
        }
    private:
        static cppjieba::Jieba jieba;
    };
    cppjieba::Jieba JiebaUtil::jieba(DICT_PATH,HMM_PATH,USER_DICT_PATH,IDF_PATH,STOP_WORD_PATH);
} // namespace ns_util
